#include "bo3d.h"

BBDECL Ogre::Light* __stdcall o_createLight(Ogre::SceneManager* scm)
{
	Ogre::Light* l;
	try
	{
		l = scm->createLight();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return l;
}

BBDECL void __stdcall o_light_setType(Ogre::Light* light, int lightType)
{
	try
	{
		light->setType(Ogre::Light::LightTypes(lightType));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL void __stdcall o_light_setPosition(Ogre::Light* light, float x, float y, float z)
{
	try
	{
		light->setPosition(Ogre::Real(x), Ogre::Real(y), Ogre::Real(z));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL void __stdcall o_light_setDiffuseColour(Ogre::Light* light, float red, float green, float blue)
{
	try
	{
		light->setDiffuseColour(Ogre::Real(red), Ogre::Real(green), Ogre::Real(blue));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

}

BBDECL void __stdcall o_light_setSpecularColour(Ogre::Light* light, float red, float green, float blue)
{
	try
	{
		light->setSpecularColour(Ogre::Real(red), Ogre::Real(green), Ogre::Real(blue));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

}

BBDECL boColourValue* __stdcall o_light_getDiffuseColour(Ogre::Light* light)
{
	Ogre::ColourValue col;
	boColourValue* bcol = new boColourValue;

	try
	{
		col = light->getDiffuseColour();
		bcol->red	= col.r;
		bcol->green	= col.g;
		bcol->blue	= col.b;
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return bcol;
}

BBDECL boColourValue* __stdcall o_light_getSpecularColour(Ogre::Light* light)
{
	Ogre::ColourValue col;
	boColourValue* bcol = new boColourValue;

	try
	{
		col = light->getSpecularColour();
		bcol->red	= col.r;
		bcol->green	= col.g;
		bcol->blue	= col.b;
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return bcol;
}

BBDECL void __stdcall o_light_setAttenuation(Ogre::Light* light, float range, float constant, float linear, float quadratic)
{
	try
	{
		light->setAttenuation(Ogre::Real(range), Ogre::Real(constant), Ogre::Real(linear), Ogre::Real(quadratic));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL float __stdcall o_light_getAttenuationRange(Ogre::Light* light)
{
	float range;
	try
	{
		range = light->getAttenuationRange();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return range;
}

BBDECL float __stdcall o_light_getAttenuationConstant(Ogre::Light* light)
{
	float constant;
	try
	{
		constant = light->getAttenuationConstant();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return constant;
}

BBDECL float __stdcall o_light_getAttenuationLinear(Ogre::Light* light)
{
	float linear;
	try
	{
		linear = light->getAttenuationLinear();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return linear;
}

BBDECL float __stdcall o_light_getAttenuationQuadric(Ogre::Light* light)
{
	float quadric;
	try
	{
		quadric = light->getAttenuationQuadric();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return quadric;
}

BBDECL boVec3* __stdcall o_light_getPosition(Ogre::Light* light)
{
	boVec3* vec3 = new boVec3;

	try
	{
		Ogre::Vector3 v = light->getPosition();
		vec3->x	= v.x;
		vec3->y = v.y;
		vec3->z = v.z;
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return vec3;
}

BBDECL void __stdcall o_light_setDirection(Ogre::Light* light, float x, float y, float z)
{
	try
	{
		light->setDirection(Ogre::Real(x), Ogre::Real(y), Ogre::Real(z));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL boVec3* __stdcall o_light_getDirection(Ogre::Light* light)
{
	boVec3* vec3 = new boVec3;
	try
	{
		Ogre::Vector3 v = light->getDirection();
		vec3->x = v.x;
		vec3->y = v.y;
		vec3->z = v.z;
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return vec3;
}

BBDECL void __stdcall o_setSpotlightRange(Ogre::Light* light, float innerAngle, float outerAngle, float falloff)
{
	try
	{
		light->setSpotlightRange(Ogre::Radian(innerAngle), Ogre::Radian(outerAngle), Ogre::Real(falloff));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL float __stdcall o_getSpotlightInnerAngle(Ogre::Light* light)
{
	float v;
	try
	{
		v = light->getSpotlightInnerAngle().valueRadians();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return v;
}

BBDECL float __stdcall o_getSpotlightOuterAngle(Ogre::Light* light)
{
	float v;
	try
	{
		v = light->getSpotlightOuterAngle().valueRadians();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return v;
}

BBDECL float __stdcall o_getSpotlightFalloff(Ogre::Light* light)
{
	float v;
	try
	{
		v = light->getSpotlightFalloff();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return v;
}

BBDECL void __stdcall o_setSpotlightOuterAngle(Ogre::Light* light, float angle)
{
	try
	{
		light->setSpotlightOuterAngle(Ogre::Radian(angle));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL void __stdcall o_setSpotlightInnerAngle(Ogre::Light* light, float angle)
{
	try
	{
		light->setSpotlightInnerAngle(Ogre::Radian(angle));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL void __stdcall o_setSpotlightFalloff(Ogre::Light* light, float falloff)
{
	try
	{
		light->setSpotlightFalloff(Ogre::Real(falloff));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL void __stdcall o_light_setPowerScale(Ogre::Light* light, float power)
{
	try
	{
		light->setPowerScale(Ogre::Real(power));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL float __stdcall o_light_getPowerScale(Ogre::Light* light)
{
	float power;
	try
	{
		power = light->getPowerScale();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return power;
}

BBDECL const char* __stdcall o_light_getMovableType(Ogre::Light* light)
{
	const char* type;
	try
	{
		type = light->getMovableType().c_str();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return type;
}

BBDECL void __stdcall o_light_setVisible(Ogre::Light* light, bool visible)
{
	try
	{
		light->setVisible(visible);
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL void __stdcall o_light_setShadowFarDistance(Ogre::Light* light, float distance)
{
	try
	{
		light->setShadowFarDistance(Ogre::Real(distance));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL void __stdcall o_light_setShadowFarClipDistance(Ogre::Light* light, float farClip)
{
	try
	{
		light->setShadowFarClipDistance(Ogre::Real(farClip));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL void __stdcall o_light_resetShadowFarDistance(Ogre::Light* light)
{
	try
	{
		light->resetShadowFarDistance();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL float __stdcall o_light_getShadowFarDistance(Ogre::Light* light)
{
	float dist;
	try
	{
		dist = light->getShadowFarDistance();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return dist;
}

BBDECL void __stdcall o_light_setShadowNearClipDistance(Ogre::Light* light, float nearClip)
{
	try
	{
		light->setShadowNearClipDistance(Ogre::Real(nearClip));
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

BBDECL float __stdcall o_light_getShadowNearClipDistance(Ogre::Light* light)
{
	float nearClip;

	try
	{
		nearClip = light->getShadowNearClipDistance();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return nearClip;
}

BBDECL float __stdcall o_light_getShadowFarClipDistance(Ogre::Light* light)
{
	float dist;

	try
	{
		dist = light->getShadowFarClipDistance();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return dist;
}

BBDECL const char* __stdcall o_light_getName(Ogre::Light* light)
{
	const char* name;

	try
	{
		name = light->getName().c_str();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return name;
}

BBDECL Ogre::Node* __stdcall o_light_getParentNode(Ogre::Light* light)
{
	Ogre::Node* node;
	try
	{
		node = light->getParentNode();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return node;
}

BBDECL Ogre::Node* __stdcall o_light_getParentSceneNode(Ogre::Light* light)
{
	Ogre::Node* node;
	try
	{
		node = light->getParentSceneNode();
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}

	return node;
}

BBDECL void __stdcall o_light_setCastShadows(Ogre::Light* light, bool enable)
{
	try
	{
		light->setCastShadows(enable);
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}